//
//  JPScoreView.m
//  TaskRabbit
//
//  Created by ShiXiong on 14-7-15.
//  Copyright (c) 2014年 junepartner. All rights reserved.
//

#import "JPScoreView.h"

@interface JPScoreView () {
    NSMutableArray *contentViews;
}

@end

@implementation JPScoreView

- (id)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)setScore:(CGFloat)score
{
    _score = score;
    
    // 移除所有的子视图
    [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    int zhengshu = (int)score;
    float xiaoshu = score - zhengshu;
    
    for (int i = 0; i < zhengshu; i ++) {
        UIImageView *starImageView = [[UIImageView alloc] initWithFrame:CGRectMake(17*i, 2.5, 15, 15)];
        starImageView.backgroundColor = [UIColor clearColor];
        starImageView.image = [UIImage imageNamed:@"star_select"];
        [self addSubview:starImageView];
    }
    
     for (int j =zhengshu; j <5 ; j ++) {
        UIImageView *starImageView = [[UIImageView alloc] initWithFrame:CGRectMake(j*17, 2.5, 15, 15)];
        starImageView.image = [UIImage imageNamed:@"star"];
        starImageView.backgroundColor = [UIColor clearColor];
        [self addSubview:starImageView];
    }
}

@end
